package com.zhbcm.netty.handler;

import com.zhbcm.netty.po.RpcResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/4/22 23:00
 */
public class ClientHandler extends SimpleChannelInboundHandler<RpcResponse>
{
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, RpcResponse rpcResponse) throws Exception
    {
        System.out.println("接受到server响应数据: " + rpcResponse.toString());
    }

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception
    {
        super.channelActive(ctx);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
    {
        ctx.close();
    }
}
